using System;
using System.Windows.Data;
using AzureDiagMon.Common.Dtos;

namespace AzureDiagMon.Common.Converters
{
    public class WadLogLevelToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                var level = value as int?;
                if (level == null)
                    return value;
                
                return ((WadLogLevel)level.Value).ToString();
            }
            catch
            {
                return value;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // Not implemented
            return null;
        }
    }
}